#!/usr/bin/env python
# -*- coding: utf-8 -*-#

#-------------------------------------------------------------------------------
# Name:         hwtest.py
# Description:  
# Author:       handa
# Date:         2022/4/18
#-------------------------------------------------------------------------------

def largest_factor(n):
    """Return the largest factor of n that is smaller than n.

        >>> largest_factor(15) # factors are 1, 3, 5
        5
        >>> largest_factor(80) # factors are 1, 2, 4, 5, 8, 10, 16, 20, 40
        40
        >>> largest_factor(13) # factor is 1 since 13 is prime
        1
        """
    "*** YOUR CODE HERE ***"
    factor_list = []
    for i in range(2,n):
        #print(i)
        if n % i == 0:
            factor_list.append(i)
            #print(factor_list)

    if len(factor_list) > 0:
        return max(factor_list)
    else:
        return 1


